package util;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

/**
 * @Author: 白熊
 * @Date: 2024/4/17 15:17
 */
public class MybatisUtil {
    public static SqlSessionFactory getSqlSessionFactory() throws IOException {
        //第一步:加载配置文件
        InputStream inputStream = Resources.getResourceAsStream("mybatis-config.xml");
        //第二步:创建核心工厂类
        SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        return sessionFactory;

    }
}
